package com.FindMyStuff.Model;

public enum ItemType {
Found("f"), Lost("l"), All("a");
	
	/**
	 * Holds the Enum Value
	 */
	private String value;
	
	/**
	 * Private Constructor to store the enum value
	 * @param string
	 */
	private ItemType(String string)
	{
		value = string;
	}
	
	/**
	 * Creates a String of the enum 
	 */
	public String toString() {
		String res = "";
	       switch (this) {
	         case Found:
	        	 res = value;
	        	 break;
	         case Lost:
	        	 res = value;
	        	 break;
	         case All:
	        	 res = value;
	        	 break;
	        }
		return res;
	 }
	
	/**
	 * Converts string into an enum 
	 * @param string value to convert
	 * @return converted enum
	 */
	public static ItemType convertToType(String string)
	{
		if(string.equals("f"))
		{
			return Found;
		}
		else if(string.equals("l"))
		{
			return Lost;
		} else
		{
			return All;
		}
		
	}
	
	/**
	 * Converts the given string to an ItemType
	 * @param string to convert
	 * @return ItemType representation of the String
	 */
	public static ItemType convertStringToType(String string) {
		if(string.equals("Found"))
		{
			return Found;
		}
		else if(string.equals("Lost"))
		{
			return Lost;
		} 
		else
		{
			return All;
		}
	}
	
	/**
	 * Checks if the given type is the same as this type
	 * @param type to check
	 * @return true if they match
	 */
	public boolean equals(ItemType type)
	{
		if(this.toString().equals(type.toString()))
		{
			return true;
		}
		return false;
	}
}
